package com.qf.admin.advice;

import com.qf.common.http.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
//controller增强器,用于捕捉全局异常
@ControllerAdvice
public class ExceptionControllerAdvice {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result<?> handleBusinessException(HttpServletRequest request,Exception e){
        String errmsg = e.getMessage();
        return Result.error(errmsg);
    }
}
